<?php
session_start();
if (isset($_POST["username"])) {
    $name = $_POST["username"];
    $pw = $_POST["password"];
    $_SESSION["username"] = $name;
    $_SESSION["password"] = $pw;
    $_SESSION["isUser"] = false;
    $_SESSION["isLg"] = true;
}
/**
 * 注销页面
 */
if (isset($_GET['action'])) {
    if ($_GET['action'] == "logout") {
//        header('Refresh:0; url="#"');
//        session_start();
        setcookie("cookiename", NULL);
        session_unset();
        session_destroy();
//        echo "<script>alert('三秒后返回登入页面')</script>";
    }
}
/**
 * 判断是否有登录值，跳转到订单页面
 */
if (isset($_GET['isOLogin'])) {
    if ($_GET['isOLogin'] == "lg") {
        if (!isset($_SESSION["isLg"])) {
            echo "<script>";
            echo "window.location.href='../login/login.php';";
            echo "</script>";
        }
    }
}

/**
 * 判断值进行添加到购物车详情操作
 */
if (isset($_GET['insert'])) {
    if ($_GET['insert'] == "icd") {
        if (!isset($_SESSION["isLg"])) {
            echo "<script>";
            echo "window.location.href='../login/login.php';";
            echo "</script>";
        }
    }
}

/**
 * 判断值进行添加到购物车详情操作
 */
if (isset($_GET['isCLogin'])) {
    if ($_GET['isCLogin'] == "clg") {
        if (!isset($_SESSION["isLg"])) {
            echo "<script>";
            echo "window.location.href='../login/login.php';";
            echo "</script>";
        }
    }
}


//setcookie(session_name(),session_id(),time()+6,"/");//设置会话cookie的过期时间
?>